package controller

import (
	"errors"
	"fmt"
	"haiqiu-go-admin/result"
	"log"
	"net/http"
	"strings"
)

var API = &Api{}

type Api struct {
}

var UserAPI = &UserApi{}

type UserApi struct {
}

var DeptAPI = &DeptApi{}

type DeptApi struct {
}

var MenuAPI = &MenuApi{}

type MenuApi struct {
}

var PostAPI = &PostApi{}

type PostApi struct {
}

var RoleAPI = &RoleApi{}

type RoleApi struct {
}

var ConfigAPI = &ConfigApi{}

type ConfigApi struct {
}

var NoticeAPI = &NoticeApi{}

type NoticeApi struct {
}

var LogAPI = &LogApi{}

type LogApi struct {
}

var LoginLogAPI = &LoginLogApi{}

type LoginLogApi struct {
}

const (
	GET    = "GET"
	POST   = "POST"
	DELETE = "DELETE"
	PUT    = "PUT"
)

// MatchRequestMethod 匹配路由请求方式
func MatchRequestMethod(method string, w http.ResponseWriter, r *http.Request) (flag bool) {
	log.Println("获取到请求路径：" + r.URL.Path + "，获取到请求方法：" + r.Method)
	m := r.Method
	if strings.ToUpper(m) != method {
		msg := fmt.Sprintf("该接口不支持%s请求", m)
		result.Fail(w, r, errors.New(msg))
		return true
	}
	return false
}

func JsonFormatStruct(interface{}) interface{} {
	return nil
}
